return ret;
}
+/**
+ * ostree_repo_remote_get_url:
+ * @self: Repo
+ * @name: Name of remote
+ * @out_url: (out) (allow-none): Remote's URL
+ * @error: Error
+ *
+ * Return the URL of the remote named @name through @out_url. It is an
+ * error if the provided remote does not exist.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
+ */
+gboolean
+ostree_repo_remote_get_url (OstreeRepo *self,
+ const char *name,
+ char **out_url,
+ GError **error)
+{
+ local_cleanup_remote OstreeRemote *remote = NULL;
+ gs_free char *url = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (name != NULL, FALSE);
+
+ remote = ost_repo_get_remote (self, name, error);
+
+ if (remote == NULL)
+ goto out;
+
+ url = g_key_file_get_string (remote->options, remote->group, "url", error);
+
+ if (url != NULL)
+ {
+ gs_transfer_out_value (out_url, &url);
+ ret = TRUE;
+ }
+
+ out:
+ return ret;
+}
+
static gboolean
ostree_repo_mode_to_string (OstreeRepoMode mode,
const char **out_mode,
GCancellable *cancellable,
GError **error);
+gboolean ostree_repo_remote_get_url (OstreeRepo *self,
+ const char *name,
+ char **out_url,
+ GError **error);
+
OstreeRepo * ostree_repo_get_parent (OstreeRepo *self);
gboolean ostree_repo_write_config (OstreeRepo *self,
gs_unref_object OstreeRepo *repo = NULL;
gboolean ret = FALSE;
const char *op;
- gs_free char *key = NULL;
guint i;
- GKeyFile *config = NULL;
const char *remote_name;
context = g_option_context_new ("OPERATION NAME [args] - Control remote repository configuration");
op = argv[1];
remote_name = argv[2];
- key = g_strdup_printf ("remote \"%s\"", remote_name);
-
- config = ostree_repo_copy_config (repo);
if (!strcmp (op, "add"))
{
{
gs_free char *url = NULL;
- url = g_key_file_get_string (config, key, "url", error);
- if (url == NULL)
+ if (!ostree_repo_remote_get_url (repo, remote_name, &url, error))
goto out;
g_print ("%s\n", url);
out:
if (context)
g_option_context_free (context);
- if (config)
- g_key_file_free (config);
return ret;
}